import 'dart:convert' show json;

class CommentInfo {
  int code;
  String msg;
  CommentData data;

  CommentInfo.fromParams({this.code, this.msg, this.data});

  factory CommentInfo(jsonStr) => jsonStr == null
      ? null
      : jsonStr is String
          ? new CommentInfo.fromJson(json.decode(jsonStr))
          : new CommentInfo.fromJson(jsonStr);

  CommentInfo.fromJson(jsonRes) {
    code = jsonRes['code'];
    msg = jsonRes['msg'];
    data = jsonRes['data'] == null
        ? null
        : new CommentData.fromJson(jsonRes['data']);
  }

  @override
  String toString() {
    return '{"code": $code,"msg": ${msg != null ? '${json.encode(msg)}' : 'null'},"data": $data}';
  }
}

class CommentData {
  int author_uid;
  CommentList hot;
  CommentList normal;

  CommentData.fromParams({this.author_uid, this.hot, this.normal});

  CommentData.fromJson(jsonRes) {
    author_uid = jsonRes['author_uid'];
    hot = jsonRes['hot'] == null
        ? null
        : new CommentList.fromJson(jsonRes['hot']);
    normal = jsonRes['normal'] == null
        ? null
        : new CommentList.fromJson(jsonRes['normal']);
  }

  @override
  String toString() {
    return '{"author_uid": $author_uid,"hot": $hot,"normal": $normal}';
  }
}

class CommentList {
  List<Comment> list;
  Info info;

  CommentList.fromParams({this.list, this.info});

  CommentList.fromJson(jsonRes) {
    list = jsonRes['list'] == null ? null : [];

    for (var listItem in list == null ? [] : jsonRes['list']) {
      list.add(listItem == null ? null : new Comment.fromJson(listItem));
    }

    info = jsonRes['info'] == null ? null : new Info.fromJson(jsonRes['info']);
  }

  @override
  String toString() {
    return '{"list": $list,"info": $info}';
  }
}

class Info {
  int count;
  int np;

  Info.fromParams({this.count, this.np});

  Info.fromJson(jsonRes) {
    count = jsonRes['count'];
    np = jsonRes['np'];
  }

  @override
  String toString() {
    return '{"count": $count,"np": $np}';
  }
}

class Comment {
  int data_id;
  int hate_count;
  int id;
  int like_count;
  int status;
  String content;
  String ctime;
  String more;
  String type;
  List<Comment> children;
  List<Comment> precmts;
  List<dynamic> vote;
  Images image;
  User user;

  Comment.fromParams(
      {this.data_id,
      this.hate_count,
      this.id,
      this.like_count,
      this.status,
      this.content,
      this.ctime,
      this.more,
      this.type,
      this.children,
      this.precmts,
      this.vote,
      this.image,
      this.user});

  Comment.fromJson(jsonRes) {
    data_id = jsonRes['data_id'];
    hate_count = jsonRes['hate_count'];
    id = jsonRes['id'];
    like_count = jsonRes['like_count'];
    status = jsonRes['status'];
    content = jsonRes['content'];
    ctime = jsonRes['ctime'];
    more = jsonRes['more'];
    type = jsonRes['type'];
    children = jsonRes['children'] == null ? null : [];

    for (var childrenItem in children == null ? [] : jsonRes['children']) {
      children.add(
          childrenItem == null ? null : new Comment.fromJson(childrenItem));
    }

    precmts = jsonRes['precmts'] == null ? null : [];

    for (var precmtsItem in precmts == null ? [] : jsonRes['precmts']) {
      precmts
          .add(precmtsItem == null ? null : new Comment.fromJson(precmtsItem));
    }

    vote = jsonRes['vote'] == null ? null : [];

    for (var voteItem in vote == null ? [] : jsonRes['vote']) {
      vote.add(voteItem);
    }

    image =
        jsonRes['image'] == null ? null : new Images.fromJson(jsonRes['image']);
    user = jsonRes['user'] == null ? null : new User.fromJson(jsonRes['user']);
  }

  @override
  String toString() {
    return '{"data_id": $data_id,"hate_count": $hate_count,"id": $id,"like_count": $like_count,"status": $status,"content": ${content != null ? '${json.encode(content)}' : 'null'},"ctime": ${ctime != null ? '${json.encode(ctime)}' : 'null'},"more": ${more != null ? '${json.encode(more)}' : 'null'},"type": ${type != null ? '${json.encode(type)}' : 'null'},"children": $children,"precmts": $precmts,"vote": $vote,"image": $image,"user": $user}';
  }
}

class User {
  int id;
  bool is_vip;
  String personal_page;
  String profile_image;
  String qq_uid;
  String qzone_uid;
  String room_icon;
  String room_name;
  String room_role;
  String room_url;
  String sex;
  String username;

  User.fromParams(
      {this.id,
      this.is_vip,
      this.personal_page,
      this.profile_image,
      this.qq_uid,
      this.qzone_uid,
      this.room_icon,
      this.room_name,
      this.room_role,
      this.room_url,
      this.sex,
      this.username});

  User.fromJson(jsonRes) {
    id = jsonRes['id'];
    is_vip = jsonRes['is_vip'];
    personal_page = jsonRes['personal_page'];
    profile_image = jsonRes['profile_image'];
    qq_uid = jsonRes['qq_uid'];
    qzone_uid = jsonRes['qzone_uid'];
    room_icon = jsonRes['room_icon'];
    room_name = jsonRes['room_name'];
    room_role = jsonRes['room_role'];
    room_url = jsonRes['room_url'];
    sex = jsonRes['sex'];
    username = jsonRes['username'];
  }

  @override
  String toString() {
    return '{"id": $id,"is_vip": $is_vip,"personal_page": ${personal_page != null ? '${json.encode(personal_page)}' : 'null'},"profile_image": ${profile_image != null ? '${json.encode(profile_image)}' : 'null'},"qq_uid": ${qq_uid != null ? '${json.encode(qq_uid)}' : 'null'},"qzone_uid": ${qzone_uid != null ? '${json.encode(qzone_uid)}' : 'null'},"room_icon": ${room_icon != null ? '${json.encode(room_icon)}' : 'null'},"room_name": ${room_name != null ? '${json.encode(room_name)}' : 'null'},"room_role": ${room_role != null ? '${json.encode(room_role)}' : 'null'},"room_url": ${room_url != null ? '${json.encode(room_url)}' : 'null'},"sex": ${sex != null ? '${json.encode(sex)}' : 'null'}},"username": ${username != null ? '${json.encode(username)}' : 'null'}}';
  }
}

class Images {
  int height;
  int width;
  List<String> download;
  List<String> images;
  List<String> thumbnail;

  Images.fromParams(
      {this.height, this.width, this.download, this.images, this.thumbnail});

  Images.fromJson(jsonRes) {
    height = jsonRes['height'];
    width = jsonRes['width'];
    download = jsonRes['download'] == null ? null : [];

    for (var downloadItem in download == null ? [] : jsonRes['download']) {
      download.add(downloadItem);
    }

    images = jsonRes['images'] == null ? null : [];

    for (var imagesItem in images == null ? [] : jsonRes['images']) {
      images.add(imagesItem);
    }

    thumbnail = jsonRes['thumbnail'] == null ? null : [];

    for (var thumbnailItem in thumbnail == null ? [] : jsonRes['thumbnail']) {
      thumbnail.add(thumbnailItem);
    }
  }

  @override
  String toString() {
    return '{"height": $height,"width": $width,"download": $download,"images": $images,"thumbnail": $thumbnail}';
  }
}
